import {observable, action, runInAction} from 'mobx';
import {Toast} from 'antd-mobile';

class PropertyFeeStore {
    @observable propertyFeeInfo = '';
    @observable isPay = -1;
    @action
    componentDidMount = () => {
        initToken(() => {
            console.log("success");
        }, () => {
            console.log("failed");
        });
        Toast.loading('正在加载...', 0, () => {
            console.log('正在加载...');
        });
        postJson("/property/fee/queryPropertyFeeByOwnerCode.x", {ownerCode: ownerCode}, (data) => {
            runInAction(() => {
                this.propertyFeeInfo = data;
                this.isPay = data.isPay;
                Toast.hide();
            });
        }, (error) => {
            this.isPay = 1;
            Toast.hide();
        });
    };

    @action
    paySubmit = (props) => {
        props.history.push('/pages/mobile/property/fee/pay', {
            id: this.propertyFeeInfo.id,
            payments: this.propertyFeeInfo.fee,
            lastBillDate: this.propertyFeeInfo.lastBillDate,
            currentBillDate: this.propertyFeeInfo.currentBillDate,
            months: this.propertyFeeInfo.months
        })
    };
}

export default new PropertyFeeStore()